using System;
using System.ComponentModel.Composition;
using MefContrib.Models.Provider.Definitions.Attributed;

namespace MefContrib.Models.Provider.Tests.Definitions
{
    #region Type Dummy Parts

    [Exportable]
    public class DefaultContractExport
    {
        
    }

    [Exportable(typeof(DefaultContractImport))]
    public class DefaultContractImport
    {
        [Importable]
        public IFoo Foo { get; set; }
    }

    public interface IMany
    {
    }

    [Exportable(typeof(IMany))]
    public class Many1 : IMany
    {
    }

    [Exportable(typeof(IMany))]
    public class Many2 : IMany
    {
    }

    public interface IFoo
    {
    }

    [Exportable(typeof(IFoo))]
    public class Foo1 : IFoo
    {
    }

    [Exportable("Foo2", typeof(IFoo))]
    public class Foo2 : IFoo
    {
    }

    [Exportable(typeof(Bar1))]
    public class Bar1
    {
        [Importable(typeof(IFoo))]
        public IFoo Foo { get; set; }

        [Importable(typeof(IMefComponent))]
        public IMefComponent MefComponent { get; set; }
    }

    [Exportable(typeof(Bar2))]
    public class Bar2
    {
        [ImportingConstructor]
        public Bar2(
            [Importable(typeof(IFoo))] 
                IFoo foo,
            
            [Importable(typeof(IMefComponent))]
                IMefComponent mefComponent)
        {
            Foo = foo;
            MefComponent = mefComponent;
        }

        public IFoo Foo { get; set; }
        
        public IMefComponent MefComponent { get; set; }
    }

    #endregion
    
    #region Property Dummy Parts

    public class PropretyExporterUsingNamedContract
    {
        public PropretyExporterUsingNamedContract()
        {
            Value = 112233;
        }

        [Exportable("Value")]
        public int Value { get; set; }
    }

    [Exportable]
    public class PropretImporterUsingNamedContract
    {
        [Importable("Value")]
        public int Value { get; set; }
    }

    public class PropretyExporterUsingDefaultContract
    {
        public PropretyExporterUsingDefaultContract()
        {
            Value = 223344;
        }

        [Exportable]
        public int Value { get; set; }
    }

    [Exportable]
    public class PropretImporterUsingDefaultContract
    {
        [Importable]
        public int Value { get; set; }
    }

    #endregion

    #region Field Dummy Parts

    public class FieldExporterUsingNamedContract
    {
        public FieldExporterUsingNamedContract()
        {
            _stringField = "test string";
        }

        [Exportable("FldValue")]
        public string _stringField;
    }

    [Exportable]
    public class FieldImporterUsingNamedContract
    {
        [Importable("FldValue")]
        public string _stringField2;
    }

    public class FieldExporterUsingDefaultContract
    {
        public FieldExporterUsingDefaultContract()
        {
            _stringField = "test string 2";
        }

        [Exportable]
        public string _stringField;
    }

    [Exportable]
    public class FieldImporterUsingDefaultContract
    {
        [Importable]
        public string _stringField2;
    }

    #endregion

    #region Method Dummy Parts

    public delegate string Bar(int x, double k);

    public class MethodExporterUsingDefaultContract
    {
        [Exportable]
        public string Bar(int x, double k)
        {
            return "Result=" + (x + k).ToString();
        }
    }

    [Exportable]
    public class MethodImporterUsingDefaultContract
    {
        [Importable]
        public Func<int, double, string> BarMethod { get; set; }
    }

    public class MethodExporterUsingNamedContract
    {
        [Exportable("method_bar")]
        public string Bar(int x, double k)
        {
            return "Result=" + (x * k).ToString();
        }
    }

    [Exportable]
    public class MethodImporterUsingNamedContract
    {
        [Importable("method_bar")]
        public Func<int, double, string> BarMethod { get; set; }
    }

    #endregion

    public interface IMefComponent
    {
    }

    [Export(typeof(IMefComponent))]
    public class MefComponent : IMefComponent
    {
    }
}